# _*_ coding:utf-8 _*_
# @Time  : 2023.02.10
# @Author: zizlee
import datetime
import json
import pandas as pd
with open('shegnzhu.json', 'r') as f:
    data = json.load(f)

start = datetime.date(2022, 2, 9)
end = datetime.date(2023, 2, 10)

datelist = []
while start <= end:
    datelist.append(start.strftime('%Y-%m-%d'))
    start += datetime.timedelta(days=1)
print(len(datelist))
print(len(data['pigprice']))

price_data = []
for price in zip(datelist, data['pigprice']):
    price_data.append({
        '日期': price[0],
        '价格': price[1]
    })

df = pd.DataFrame(price_data)
df.to_excel('生猪价格.xlsx', index=False, encoding='utf8')

